#include <stdio.h>
#include <stdlib.h>
typedef struct ListNode {
    int value;
    struct ListNode *next;
} ListNode;

ListNode* createNode(int value) {
    ListNode *newNode = (ListNode*)malloc(sizeof(ListNode));
    if (!newNode) {
        exit(1);
    }
    newNode->value = value;
    newNode->next = NULL;
    return newNode;
}

int main(){
    int n;
    scanf("%d",&n);
    ListNode *head=NULL,*tail=NULL;
    for (int i = 0; i < n; ++i) {
        int value;
        scanf("%d", &value);
        if (head == NULL) {
            head = createNode(value);
            tail = head;
        } else {
            tail->next = createNode(value);
            tail = tail->next;
        }
    }
    ListNode *current = head;
    ListNode *min=head;
    ListNode *minbefore=NULL;
    while (current->next!=NULL){
        if (current->next->value<min->value){
            minbefore=current;
            min=current->next;
        }
        current=current->next;
    }
    if (minbefore==NULL){
        head=head->next;
        free(min);
    }
    else{
        minbefore->next=min->next;
        free(min);
    }
    while (head!=NULL){
        printf("%d ",head->value);
        head=head->next;
    }
    return 0;
}